package wu.example.orderserver.filter;

import io.netty.util.internal.StringUtil;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @author benjamin_5
 * @Description
 * @date 2024/8/28
 */
@Activate(group = "auth", value = "id")
public class AuthFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        String token = RpcContext.getClientAttachment().getAttachment("auth");
        if(StringUtil.isNullOrEmpty(token)){
            throw new RuntimeException("token为空");
        }
        Result result = invoker.invoke(invocation);
        return result;
    }
}
